﻿// -----------------------------------------------------------------------
// Copyright (c) David Kean. All rights reserved.
// -----------------------------------------------------------------------
extern alias pcl;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

using SHA1Managed = pcl::System.Security.Cryptography.SHA1Managed;
using IHashAlgorithm = pcl::System.Security.Cryptography.Adaptation.IHashAlgorithm;
using PlatformAdapter = pcl::System.Adaptation.PlatformAdapter;

namespace Portable.Security.Cryptography
{
    [TestClass]
    public class SHA1ManagedTests
    {
        [TestMethod]
        public void Constructor_PassesPlatformAdapterCurrentCreateSha1ManagedToBase()
        {
            var underlyingAlgorithm = MockFactory.Create<IHashAlgorithm>();
            var adapter = ICryptographyAdapterFactory.Override(a => a.CreateSha1Managed(), underlyingAlgorithm);
            var resolver = IAdapterResolverFactory.OverrideResolve(type => adapter);
            PlatformAdapter.SetResolver(resolver);

            var algorithm = new SHA1Managed();

            Assert.AreSame(underlyingAlgorithm, algorithm.UnderlyingAlgorithm);
        }
    }
}
